package com.hedl.studyandjava8.java8_1unit.java8_12;

import com.hedl.studyandjava8.java8_1unit.java8_12.entity.Apple;
import com.hedl.studyandjava8.java8_1unit.java8_12.entity.Color;
import com.hedl.studyandjava8.java8_1unit.java8_12.service.Predicate;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Big Watermelon
 * @description
 * @date 2024/01/19/20:24
 */
public class TestMain {

    List<Apple> list = new ArrayList<>();

    public static boolean isGreenApple(Apple apple){
        return apple.getWeight() > 150;
    }

    public static List<Apple> filterApples(List<Apple> inventory, Predicate<Apple> p){
        List<Apple> result = new ArrayList<>();
        for (Apple apple:inventory){
            if (p.test(apple)){
                result.add(apple);
            }
        }
        return result;
    }

    public static void main(String[] args) {

        Apple apple = new Apple();
        apple.setWeight(100);
        apple.setColor(Color.RED);
        List<Apple> inventory = new ArrayList<>();

        //List<Apple> apples = filterApples(inventory, TestMain::isGreenApple);
        //System.out.println(apples);
        inventory.add(apple);

    }
}
